﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonPocGarage.ArmyContracts.Common.Enums;

namespace MonPocGarage.ArmyContracts.Common.Abilities
{
    public class Action : IAbility
    {
        private AbilityColor m_AbilityColor;
        private readonly string m_AbilityID;
        private readonly string m_AbilityName;
        private readonly string m_AbilityDescription;

        public string AbilityID
        {
            get { return m_AbilityID; }
        }

        public AbilityType AbilityType
        {
            get { return AbilityType.Action; }
        }

        public AbilityColor AbilityColor
        {
            get { return m_AbilityColor; }
        }

        public string AbilityName
        {
            get { return m_AbilityName; }
        }

        public string AbilityDescription
        {
            get { return m_AbilityDescription; }
        }

        public string ImagePath
        {
            get { return BuildImagePath(); }
        }

        public void ChangeColor(AbilityColor newColor)
        {
            m_AbilityColor = newColor;
        }

        public Action(string abilityName, string abilityDescription, AbilityColor color)
        {
            m_AbilityColor = color;
            m_AbilityName = abilityName;
            m_AbilityDescription = abilityDescription;
            m_AbilityID = m_AbilityName.Replace(" ", string.Empty);
        }

        private Action(Action another)
        {
            m_AbilityColor = another.AbilityColor;
            m_AbilityDescription = another.AbilityDescription;
            m_AbilityID = another.AbilityID;
            m_AbilityName = another.AbilityName;
        }

        private string BuildImagePath()
        {
            if (!string.IsNullOrWhiteSpace(m_AbilityID))
            {
                string imagePath = string.Format("{0}/Images/Abilities/Actions/action_{1}{2}.png",
                                                 Environment.CurrentDirectory,
                                                 m_AbilityID.ToLower(),
                                                 m_AbilityColor != AbilityColor.Black
                                                     ? "_" + m_AbilityColor.ToString().ToLower()
                                                     : string.Empty);
                return imagePath;
            }
            return string.Empty;
        }

        public object Clone()
        {
            return new Action(this);
        }
    }
}
